/**
 * 轮播图js
 * rotation_chart
 * */
var 
	  prevBtn = document.getElementById("prev_btn"),
	  nextBtn = document.getElementById("next_btn"),
	  rotationBody = document.getElementById("rotation_body"),
	  rotationList = rotationBody.children,
	  index = 0,
	  timer = null,
	  length = rotationList.length;
	  
    // 函数

    function init(){
          rotationBody.style.width = 100 * rotationList.length + "%";
    }
    function toNext(){
          if(index === length - 1){
                index = 0;
          }else{
                index ++;
          }
          animate("next");
    }
    function toPrev(){
          if(index === 0){
                index = length - 1;
          }else{
                index --;
          }
          animate("prev");
    }
    function animate(arg){//处理业务
          if(index === 0 && arg === "next"){
                // alert();
                rotationBody.style.left = 0;
                index ++;
          }
          if(index === length - 1 && arg === "prev"){
                // alert();
                rotationBody.style.left = -(length - 1) * 1131 + "px";
                index --;

          }
          move(rotationBody,-index*1131,"left");
    }

    // 事件;
    prevBtn.addEventListener("click",toPrev)
    nextBtn.addEventListener("click",toNext)
    init();
    setInterval(toNext,5000)
    


//鼠标滑过改变button的属性

rotationBody.onmouseover = function(){
	prevBtn.style.display = "block";
	nextBtn.style.display = "block";
}
rotationBody.onmouseleave = function(){
	prevBtn.style.display = "none";
	nextBtn.style.display = "none";
}


//菜单黏性定位
var menuBody = document.getElementById("menu_body"),
	gotop = document.getElementById("gotop");
window.onscroll = function(){
      var scrollTop = document.documentElement.scrollTop;
      if(scrollTop >= 500){
      		gotop.style.display = "block";
      		menuBody.style.marginTop = "0";
            menuBody.style.position = "fixed";
      }else{
      		menuBody.style.marginTop = "21px";
            menuBody.style.position = "static";
            gotop.style.display = "none";
      }
}



//回到顶部
gotop.onclick = function(){
      document.documentElement.scrollTop = 0;
      document.body.scrollTop = 0;
}
//字符串拼接
var json = [
                  {
                        img : "https://img.zcool.cn/community/01f3205ca89f22a801214168a5e2af.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0174025ca5d01da8012141685bf1d9.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/015dda5c81d8a1a80120af9ac44a45.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/017b525ca5cbc3a801208f8b701d3c.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/011cd45ca5bae4a801208f8b70c123.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0164415ca756c5a801214168c14a38.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0197515ca71c4da801208f8bfc422f.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/01046d5ca5967ca801208f8b5d2df5.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/01d7125ca5a3d8a801214168eab642.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/01e0f45ca58238a8012141686796c1.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/01f3205ca89f22a801214168a5e2af.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0174025ca5d01da8012141685bf1d9.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/015dda5c81d8a1a80120af9ac44a45.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/017b525ca5cbc3a801208f8b701d3c.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/011cd45ca5bae4a801208f8b70c123.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0164415ca756c5a801214168c14a38.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0197515ca71c4da801208f8bfc422f.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/01046d5ca5967ca801208f8b5d2df5.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/01d7125ca5a3d8a801214168eab642.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/01e0f45ca58238a8012141686796c1.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/01f3205ca89f22a801214168a5e2af.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0174025ca5d01da8012141685bf1d9.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/015dda5c81d8a1a80120af9ac44a45.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/017b525ca5cbc3a801208f8b701d3c.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/011cd45ca5bae4a801208f8b70c123.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0164415ca756c5a801214168c14a38.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0197515ca71c4da801208f8bfc422f.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/01046d5ca5967ca801208f8b5d2df5.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/01d7125ca5a3d8a801214168eab642.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/01e0f45ca58238a8012141686796c1.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/01f3205ca89f22a801214168a5e2af.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0174025ca5d01da8012141685bf1d9.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/015dda5c81d8a1a80120af9ac44a45.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/017b525ca5cbc3a801208f8b701d3c.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/011cd45ca5bae4a801208f8b70c123.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0164415ca756c5a801214168c14a38.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  },
                  {
                        img : "https://img.zcool.cn/community/0197515ca71c4da801208f8bfc422f.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/01046d5ca5967ca801208f8b5d2df5.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/01d7125ca5a3d8a801214168eab642.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
                  ,
                  {
                        img : "https://img.zcool.cn/community/01e0f45ca58238a8012141686796c1.jpg@260w_195h_1c_1e_1o_100sh.jpg",
                        content_display_p1 : "舞术",
                        content_display_p2 : "纯艺术-速写",
                        content_display_span1 : "182",
                        content_display_span2 : "2",
                        content_display_span3 : "24",
                        content_span1 : "蚂蚁",
                        content_span2 : "1天前"
                  }
            ]



var contentBody1 = document.getElementById("content_body1");
var contentBody2 = document.getElementById("content_body2");
var contentBody3 = document.getElementById("content_body3");
var contentBody4 = document.getElementById("content_body4");
var contentBody5 = document.getElementById("content_body5");
var contentBody6 = document.getElementById("content_body6");
var contentBody7 = document.getElementById("content_body7");
var contentBody8 = document.getElementById("content_body8");
 var str = "";
for(var i = 0 ; i < json.length ; i ++){
      // console.log(json[i]);
            str += '<dl>'+
					'<dt><a href=""><img src="'+json[i].img+'" alt="" /></a></dt>'+
					'<dd>'+
						'<div class="content_display_div1">'+
							'<p class="content_display_p1">'+json[i].content_display_p1+'</p>'+
							'<p class="content_display_p2">'+json[i].content_display_p2+'</p>'+
							'<p class="content_display_p3">'+
								'<span class="content_display_span1">'+json[i].content_display_span1+'</span>'+
								'<span class="content_display_span2">'+json[i].content_display_span2+'</span>'+
								'<span class="content_display_span3">'+json[i].content_display_span3+'</span>'+
							'</p>'+
						'</div>'+
						'<div class="content_display_div2">'+
							'<span class="content_span1">'+json[i].content_span1+'</span>'+
							'<span class="content_span2">'+json[i].content_span1+'</span>'+
						'</div>'+
					'</dd>'+
				'</dl>'
}
contentBody1.innerHTML = str;

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
	if(xhr.readyState === 4 && xhr.status === 200){
		var zcoolData = JSON.parse(xhr.responseText);
		var arrA = zcoolData.data.contents;
		console.log(zcoolData,zcoolData.data.contents);
			var ajax = document.querySelector(".ajax");
			var str1 = "";
			for (var i = 0; i < arrA.length; i++) {
						str1 += '<div class="ajaxbody">'+
								'<a href="'+ arrA[i].pageUrl +'"><img src="'+ arrA[i].cover +'" alt="" /></a>'+
								'<span>'+arrA[i].title+'</span>'+
							'	</div>'
							
				}
			ajax.innerHTML = str1;
   	}
}
xhr.open("GET","../zcool.json");
xhr.send(null);


